package com.mtzqc.common.ui.activity

import android.view.LayoutInflater
import android.view.View
import androidx.viewbinding.ViewBinding
import com.mtzqc.common.R

abstract class BarBindingActivity<VB : ViewBinding, BAR : ViewBinding>(
    inflate: (LayoutInflater) -> VB, var barInflate: (View) -> BAR? = { null }
) : ViewBindingActivity<VB>(inflate) {

    private var _bar: BAR? = null

    fun barBinding(): BAR? {
        return _bar
    }

    override fun setContentView() {
        super.setContentView()
        barBinding()?.let {
            initBar(it)
        }
    }

    override fun titleBarView(view: View?): View? {
        return view?.let {
            barInflate.invoke(it)?.let { br ->
                getTitleBar(br)
            }
        }
    }



    abstract fun getTitleBar(bar: BAR): View?

    abstract fun initBar(bar: BAR)
}